package com.gxwy.admin.dao;

import java.util.List;


import org.hibernate.Query;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.gxwy.admin.form.Admin;
@Repository
public class AdminDaoImpl implements AdminDao {
	@Autowired	
	private SessionFactory sessionFactory;
   
	@SuppressWarnings("unused")
	@Transactional
	public int  listContact(Admin admin) {
		   String hql="select count(*) from users u where u.username=:customername and password=:pass";
		   Query query= sessionFactory.getCurrentSession().createSQLQuery(hql);
           query.setParameter("customername",admin.getUsername());
           query.setParameter("pass",admin.getPassword());
   		List<?> list=((org.hibernate.Query) query).list();
	     System.out.println(list.get(0));
	     for(int i=0;i<list.size();i++){
	    	 int a=Integer.valueOf(list.get(i).toString());     
	    	 System.out.println(a);
	    	 return a;
       }
	     	return 0;
	}

}
